<?php $this->load->view('_header') 
?>
<script type="text/javascript">
$(document).ready(function(){
    $("input[id^='tbx']")
    .focus(function(){
        $(this).css("background","#CBFE9F");
    	})
    .blur(function(){
        $(this).css("background","#FFF");
        var callFunName = $(this).attr("id")+"_myValidator();";
        eval(callFunName);
        }); 

 
	$("#reg_choose").attr("checked",false);
	$("#reg_choose").click(function(){
		if( $("#reg_choose").attr("checked") == true ){
			checkRegCondition(4, 1);
			}
		else
			checkRegCondition(4, 0);

		});

    $("#ibtRegister").click(function(){
    	tbxRegisterNickname_myValidator();
    	tbxRegisterPassword_myValidator();
    	tbxRegisterRepeatPassword_myValidator();
    	tbxRegisterEmail_myValidator();
		if( $("#ibtRegister").attr("name") == 31){
		 
			$("#form1").submit();
			}
		else {
			return false;
			
			}
        });
   
}); 


function checkRegCondition( index, flag ){ 
	var canSubmit = $("#ibtRegister").attr("name");
	if(flag == 0){
		var temp = ~(1 << index);

		canSubmit &= temp; 

		$("#ibtRegister").attr("name",canSubmit);
		}
	if( flag > 0 ){
		var temp2 = (1 << index);
		canSubmit |= temp2; 
			$("#ibtRegister").attr("name",canSubmit);
		}

}

// 检测用户名
function tbxRegisterNickname_myValidator( ){
 
	$("#registerNickname").html("正在检测用户名是否重复...");
	$("#registerNickname").show();
	// 检测长度
	if(  $("#tbxRegisterNickname").val().length < 3 )
	{
		$("#registerNickname").html("用户名长度必须是3-50之间");
		$("#registerNickname").css("color","red");
		//$("#ibtRegister").attr("name","ibtRegister_0");
		checkRegCondition( 0, 0);
		return ;
		}
	// 检测是否重复
	var url = "<?php echo base_url().'login/check_name'?>";
	var param = [
				 	{ 	name : 'id', value : "tbxRegisterNickname"},
				 	{ 	name : 'id_name', value : $("#tbxRegisterNickname").val()}
				 ];

    $.ajax({
        url:url,
        type: 'POST',         //数据发送方式
        dataType: 'json',     //接受数据格式
        data: param,         //要传递的数据
        success:function(data){
    		if(data.Result == true ){// 用户名可用
        		$("#registerNickname").html("该用户名可用");
        		$("#registerNickname").css("color","green");
        		checkRegCondition( 0, 1);
        	}
    		else{// 用户名冲突
    			 
    			$("#registerNickname").html("该用户名已存在");
    			$("#registerNickname").css("color","red");
    			checkRegCondition( 0, 0);
        		}
	     }, 
    	 error:function(XMLHttpRequest,textStatus){

 		   checkRegCondition( 0, 0);
		 }
      });
	
}




function isValidMail(sText) {
	 var reMail = /^(?:[a-z\d]+[_\-\+\.]?)*[a-z\d]+@(?:([a-z\d]+\-?)*[a-z\d]+\.)+([a-z]{2,})+$/i;
	// alert(reMail.test(sText));
	 return reMail.test(sText);
	}

// 输入密码
function tbxRegisterPassword_myValidator( ){
	if(  $("#tbxRegisterPassword").val().length < 3 )
	{
		$("#registerPassword").html("密码长度必须是3-30位之间");
		$("#registerPassword").css("color","red");
		//$("#ibtRegister").attr("name","ibtRegister_0");
		checkRegCondition( 1, 0);
		return 0;
		}
	else{
		$("#registerPassword").html("3-30位字符");
		$("#registerPassword").css("color","#999999");
		//$("#ibtRegister").attr("name","ibtRegister_1");
		checkRegCondition( 1, 1);
		return 1;
		}
	
}
// 再次输入密码
function tbxRegisterRepeatPassword_myValidator( ){

	if (tbxRegisterPassword_myValidator() == 0)
		return 0;
	if($("#tbxRegisterRepeatPassword").val() != $("#tbxRegisterPassword").val()){
		$("#registerPassword").html("两次密码输入不一致");
		$("#registerPassword").show();
		$("#registerPassword").css("color","red");
		//$("#ibtRegister").attr("name","ibtRegister_0");
		checkRegCondition( 2, 0);
		}
	else{
		$("#registerPassword").html("3-30位字符");
		$("#registerPassword").show();
		$("#registerPassword").css("color","#999999");
		//$("#ibtRegister").attr("name","ibtRegister_1");
		checkRegCondition( 2, 1);
		}
	
}



//检测邮箱
function tbxRegisterEmail_myValidator( ){

  // 检测邮箱格式
  var email = $("#tbxRegisterEmail").val();
  if(isValidMail(email) == false)
  {
		$("#registerEmail").html("邮箱格式不正确");
		$("#registerEmail").css("color","red");
		checkRegCondition( 3, 0);
		return;
      }

	//
	var url = "<?php echo base_url().'login/check_email'?>";
	var param = [
				 	{ 	name : 'id', value : "tbxRegisterEmail"},
				 	{ 	name : 'id_name', value : $("#tbxRegisterEmail").val()}
				 ];
	$("#registerEmail").html("正在检测邮箱是否重复...");
	$("#registerEmail").show();
  $.ajax({
      url:url,
      type: 'POST',         //数据发送方式
      dataType: 'json',     //接受数据格式
      data: param,         //要传递的数据
      success:function(data){
  		if(data.Result == true ){// 用户名可用
      		
      		$("#registerEmail").html("该邮箱可用");
      		$("#registerEmail").css("color","green");
 
      		checkRegCondition( 3, 1);
      	}
  		else{// 用户名冲突
  			 
  			$("#registerEmail").html("该邮箱已存在");
  			$("#registerEmail").css("color","red");
 
  			checkRegCondition( 3, 0);
      		}
	     }, 
  	 error:function(XMLHttpRequest,textStatus){
		   // alert(textStatus);
		    checkRegCondition( 3, 0);
		 }
    });

}



function change_yzm(obj)
{

    $(obj).attr('src','<?php echo base_url().'login/yzm_img'?>'+'/'+Math.random());
}

function change_yzm1(obj)
{

    $(obj).attr('src','<?php echo base_url().'login/yzm_img1'?>'+'/'+Math.random());
}

</script>

<div class="Main">

<!-- 以下是登录部分 -->
<form name="form1" method="post" action="<?php echo base_url().'login/check_customer'?>" onsubmit="" id="form1">
  
  <input name="loginPreURL" id="loginPreURL" type="text" style="display:none" value="<?php echo $preurl?>" />
  <div class="mleft">
 
	<div class="lo_corner_c">
	  <h2 class="logon">
	    <div class="lo_h2_left"></div>
		<div class="lo_h2_right"></div>	登录  </h2>
	  <div class="lo_child">
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;用户名：<input value="" name="tbxLoginNickname" maxlength="50" id="tbxLoginNickname" type="text">
		<div style="display: none;" id="loginNickname"></div>
	  </div>
	  <div class="lo_child">
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码：<input name="tbxLoginPassword" maxlength="50" id="tbxLoginPassword" type="password">
		<div style="display: none;" id="loginPassword"></div>
		<div class="onError"><span id="cvlLoginUser" style="color: Red; display: <?php if($error_msg) echo "block";else echo "none";?>;">
		用户名或密码错误</span></div>
	  </div>	
	  <div style="height: 290px;">
	    <div id="pnlVerifier" class="lo_child yzm" style="display:none">
	    	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码：
	    	<input name="tbxLoginVerifier" maxlength="5" id="tbxLoginVerifier" autocomplete="off" type="text">
		  <div class="onError" style="overflow: hidden;">
		    <span id="cvlLoginVerifier" style="color: Red; display: none; float: left; margin-right: 5px;">验证码错误</span>
		    <em id="loginVerifier" style="padding-left: 0pt; float: left; display: none;"></em>
		  </div>
		  <input name="hflLoginTimes" id="hflLoginTimes" type="hidden">
		  <div class="yzm_img">
		    <img src="<?php echo base_url().'login/yzm_img1'?>" id="ivrLoginVerifier" onclick="change_yzm1(this)">
		  </div>
	    </div>
 
	    <div class="lo_submit2 lo_submit3">
	      <input name="ibtLogin" id="ibtLogin" src="/images/Login_bg_38_2.gif" 
	      onclick="" style="border-width: 0px;" type="image">&nbsp;
	      <a href="#" class="grey" style="display:none">忘记密码？</a>
	    </div>
	  </div>
	</div><!-- /lo_corner_c -->
 
  </div><!-- /mleft -->
</form>



<!-- 以下是注册部分 -->
<form name="form1" method="post" action="<?php echo base_url().'login/save'?>" onsubmit="" id="form1">
  <input name="loginPreURL" id="registerPreURL" type="text" style="display:none" value="<?php echo $preurl?>" />
  <div class="mright">
	<div class="lo_corner_c">
	  <h2 class="login">
	    <div class="lo_h2_left"></div>
		<div class="lo_h2_right"></div>
		<span class="float_Right"></span>注册</em>
	  </h2>
	  <div class="onError"><span id="cvlRegister" style="color: Red; display: none;">注册信息错误</span></div>
	  <div class="lo_child">
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;用户名：<input name="tbxRegisterNickname" maxlength="50" id="tbxRegisterNickname" type="text">
		<div class="onShow" id="registerNickname">3-50位字符</div>
		<input name="hflRegisterNickname" id="hflRegisterNickname" type="hidden">
	  </div>
	  <div class="lo_child">
		&nbsp;&nbsp;&nbsp;&nbsp;输入密码：<input name="tbxRegisterPassword" maxlength="30" id="tbxRegisterPassword" type="password"><div id="pwdStrengh" style="display: none;">密码强度：</div>
		<div class="onShow" id="registerPassword">3-30位字符</div>
		<input name="hflRegisterPassword" id="hflRegisterPassword" type="hidden">
	  </div>
	  <div class="lo_child">
	    再次输入密码：<input name="tbxRegisterRepeatPassword" maxlength="30" id="tbxRegisterRepeatPassword" type="password"><div style="display: none;" id="registerRepeatPassword"></div>
	  </div>
	  <div class="lo_child">
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮&nbsp;&nbsp;&nbsp;&nbsp;箱：&nbsp;<input name="tbxRegisterEmail" maxlength="50" id="tbxRegisterEmail" type="text">&nbsp;
	    <div class="onShow" id="registerEmail"></div>
	    <input name="hflRegisterEmail" id="hflRegisterEmail" type="hidden">
	  </div>
	  
	  <div class="lo_child yzm" style="display:none">
	    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码：<input name="tbxRegisterVerifier" maxlength="5" id="tbxRegisterVerifier" autocomplete="off" type="text">
	    <div style="display: none;" id="registerVerifier"></div>
	    <div class="yzm_img" >
		  <img src="<?php echo base_url().'login/yzm_img'?>" id="ivrRegisterVerifier" onclick="change_yzm(this)" />
		</div>
	  </div>

	  <div class="lo_child align_Center">
	    <input id="reg_choose" class="radio" checked="checked" type="checkbox">&nbsp;我已阅读并同意<a href="" target="_blank">《送饭啦用户协议》</a><div style="display: none;" id="agreement"></div>
	  </div>
	  
	  
	  <!-- 注册按钮 -->
	  <div class="lo_submit">
	    <input name="0" id="ibtRegister"  src="/images/bottom_login.gif" 
	    style="border-width: 0px;" type="image">
	  </div>
	  
	</div><!-- /lo_corner_c -->
  </div> <!-- /mright -->

</form>    

</div><!-- /Main -->

 


<?php $this->load->view('_footer') ?>